<?php

	require_once "User.php";
	
	final class SmRoot0v0r01_Sudoer extends SmRoot0v0r01_User implements SmRoot_Sudoer{
		
		protected $sudo_flag;
		
		protected function fresh_login($time){
			parent::fresh_login($time);
			if($this->do_sudo) $this->edits['sudo_expires'] = $this->edits['ses_expires'];
		}
		
		function pass_check($sha1, $salt, $do_sudo=false){
			$this->sudo_flag = $do_sudo;
			return parent::pass_check($sha1, $salt);
		}
		
		function sudo_flagged(){
			return $this->sudo_flag;	
		}
		
		function is_root(){
			return ($this->session->sudo_x > time());
		}
		
		protected function sudo_perms(){
			if(!is_object($this->data->sudo_perms)){
				if($this->data->sudo_perms) $this->data->sudo_perms = @unserialize($this->data->sudo_perms);
				if(!$this->data->sudo_perms) $this->data->sudo_perms = new sjo;
				$this->edits['sudo_perms'] = $this->data->sudo_perms;
			}
			return $this->data->sudo_perms;
		}
		
		function can_script(){
			return $this->sudo_perms()->get('script');
		}

		function can_apache(){
			return $this->sudo_perms()->get('apache');
		}
		
		function can_symlink(){
			return $this->sudo_perms()->get('symlink');
		}
		
		protected function set_sudo_perms(){
			return smuoi_is_root(usr());
		}
		
		protected function set_can_script($b){
			$this->sudo_perms()->script = (int)(bool)$b;
			return false;
		}

		protected function set_can_apache($b){
			$this->sudo_perms()->apache = (int)(bool)$b;
			return false;
		}
		
		protected function set_can_symlink($b){
			$this->sudo_perms()->symlink = (int)(bool)$b;
			return false;
		}
		
	}


?>